function a(a) {
    var e = !0;
    return 11 != a.length && (e = !1), /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(18[0-9]{1})|(17[0-9]{1})|（19[0-9]{1})+\d{8})$/.test(a) || (e = !1), 
    e;
}

var e = require("../../utils/api.js"), t = require("../../wxParse/wxParse.js"), o = getApp();

Page({
    data: {
        name: "",
        phone: "",
        wx: "",
        store: "",
        adr: "",
        region: [ "北京市", "北京市", "东城区" ],
        customItem: "全部",
        footer: [],
        carnum: wx.getStorageSync("cartnum"),
        code: "",
        diy_community_name: o.globalData.diy_community_name
    },
    onLoad: function(a) {
        var n = this;
        wx.setNavigationBarColor({
            frontColor: wx.getStorageSync("basic").topcolor,
            backgroundColor: wx.getStorageSync("basic").topbg
        }), e.getMember({
            openid: o.globalData.openid
        }).then(function(a) {
            console.log(a), 2 == a.data.m_is_head && wx.redirectTo({
                url: "/pages/groupCenter/index"
            });
        }), e.GetApplyHeadSet({
            openid: o.globalData.openid
        }).then(function(a) {
            0 == a.errno && (n.setData({
                apply_head_img: a.data.apply_head_img.value,
                next_data: a.data.apply_head_text.value
            }), t.wxParse("article", "html", a.data.apply_head_img.value, n, 5));
        });
    },
    Input: function(a) {
        var e = this, t = a.detail.value, o = a.currentTarget.dataset.name;
        "name" == o ? e.setData({
            name: t
        }) : "phone" == o ? e.setData({
            phone: t
        }) : "wx" == o ? e.setData({
            wx: t
        }) : "store" == o ? e.setData({
            store: t
        }) : "adr" == o ? e.setData({
            adr: t
        }) : "code" == o ? e.setData({
            code: t
        }) : "adrdetail" == o && e.setData({
            adrdetail: t
        });
    },
    bindRegionChange: function(a) {
        console.log("picker发送选择改变，携带值为", a.detail.value), this.setData({
            region: a.detail.value
        });
    },
    getWxaddress: function(a) {
        var t = this;
        wx.chooseLocation({
            success: function(a) {
                console.log(a), console.log(a.provinceName), console.log(a.cityName), console.log(a.countyName), 
                t.setData({
                    adr: a.name,
                    lng: a.longitude,
                    lat: a.latitude
                }), e.GetSnMd5({
                    lng: a.longitude,
                    lat: a.latitude
                }).then(function(a) {
                    console.log(a), t.setData({
                        "region[0]": a.data.province.name,
                        "region[1]": a.data.city.name,
                        "region[2]": a.data.area.name
                    });
                });
            },
            fail: function() {
                console.log("获取地址失败");
            }
        });
    },
    btn: function(t) {
        var o = this, n = o.data.name, r = o.data.phone, i = o.data.store, d = o.data.adr, s = o.data.adrdetail, l = (o.data.code, 
        o.data.region[0] + o.data.region[1] + o.data.region[2]);
        o.data.code;
        if ("" == l || void 0 == l) return wx.showToast({
            title: "请选择地区",
            icon: "none",
            duration: 2e3
        }), !1;
        if ("" == i || void 0 == i) return wx.showToast({
            title: "请填写" + o.data.diy_community_name + "店名",
            icon: "none",
            duration: 2e3
        }), !1;
        if ("" == d || void 0 == d) return wx.showToast({
            title: "请先定位",
            icon: "none",
            duration: 2e3
        }), !1;
        if ("" == s || void 0 == s) return wx.showToast({
            title: "请填写详细地址",
            icon: "none",
            duration: 2e3
        }), !1;
        if (!a(r)) return wx.showToast({
            title: "请填写正确的手机号",
            icon: "none",
            duration: 2e3
        }), !1;
        if ("" == n || void 0 == n) return wx.showToast({
            title: "请填写姓名",
            icon: "none",
            duration: 2e3
        }), !1;
        var u = {
            openid: wx.getStorageSync("openid"),
            name: n,
            phone: r,
            shop_name: i,
            account: o.data.wx,
            address: d,
            adrdetail: s,
            lng: o.data.lng,
            lat: o.data.lat,
            recommend_code: o.data.code,
            formId: t.detail.formId,
            region: o.data.region[0] + "," + o.data.region[1] + "," + o.data.region[2]
        };
        console.log(u), e.applyHead(u).then(function(a) {
            wx.showToast({
                title: a.message,
                icon: "none",
                duration: 2e3
            }), 0 == a.errno && (wx.showToast({
                title: a.message,
                icon: "none",
                duration: 2e3
            }), setTimeout(function(a) {
                wx.reLaunch({
                    url: "/pages/personal/personal"
                });
            }, 2e3));
        });
    },
    sites: function(a) {
        var e = this;
        console.log(a);
        var t = a.currentTarget.dataset.data_index, o = e.data.footer;
        "url" == o.params.data[t].type ? wx.reLaunch({
            url: o.params.data[t].url
        }) : "tel" == o.params.data[t].type ? wx.makePhoneCall({
            phoneNumber: o.params.data[t].url
        }) : "out_link" == o.params.data[t].type ? wx.navigateTo({
            url: "/pages/template/out_h5?url=" + o.params.data[t].url
        }) : "app" == o.params.data[t].type && wx.navigateToMiniProgram({
            appId: o.params.data[t].url_name,
            path: o.params.data[t].url,
            envVersion: "develop",
            success: function(a) {}
        });
    },
    toHome: function(a) {
        wx.reLaunch({
            url: "/pages/template/index"
        });
    }
});